package a51qindian.com.comprehensive.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import a51qindian.com.comprehensive.R;
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Author: Li
 * Date: 2017/9/13 0013
 * Description: 任务：未接受
 */

public class TaskUnAcceptedAdapter extends RecyclerView.Adapter<TaskUnAcceptedAdapter.TaskUnAcceptedHolder> {



    private LayoutInflater mInflater;

    public TaskUnAcceptedAdapter(Context context) {
        mInflater = LayoutInflater.from(context);
    }

    private OnUnAcceptedOpListener mUnAcceptedOpListener;
    @Override
    public TaskUnAcceptedHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.item_task_un_accepted, parent, false);
        TaskUnAcceptedHolder holder = new TaskUnAcceptedHolder(view);
        if (mUnAcceptedOpListener != null) {
            holder.mTxtCall.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mUnAcceptedOpListener.onCall("18852996181");
                }
            });
            holder.mTxtAccept.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mUnAcceptedOpListener.onAccept();
                }
            });
        }
        return holder;
    }

    @Override
    public void onBindViewHolder(TaskUnAcceptedHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return 10;
    }

    public void setUnAcceptedOpListener(OnUnAcceptedOpListener unAcceptedOpListener) {
        mUnAcceptedOpListener = unAcceptedOpListener;
    }

    static class TaskUnAcceptedHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.txt_call)
        TextView mTxtCall;
        @BindView(R.id.txt_accept)
        TextView mTxtAccept;
        public TaskUnAcceptedHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
    public interface OnUnAcceptedOpListener{
        void onCall(String phone);
        void onAccept();
    }
}
